/********************************************************************************
 * Copyright(c) 2020-2025 BST All rights reserved.
 * - Filename
 * - Author
 * - Version V1.0.0
 * - Date    2023/07/04
 * - Brief
 * - FunctionList:
 ******************************************************************************
 * History:
 *
 *
 *
 ******************************************************************************
 */
#pragma once

#include "lpc/LidarFrame.pb.h"
#include <map>
#include <memory>
#include <string>
#include <set>

namespace lpc
{
  struct LidarConfig
  {
    struct Single
    {
      Single(uint8_t id, std::string& ip, int portData, int portDevice, std::string& vendor);
      uint8_t id;
      std::string ip;
      int portData;
      int portDevice;
      std::string vendor;
    };
    void add(uint8_t id,  std::string &ip, int portData, int portDevice, std::string& vendor);

    std::map<uint8_t, Single> configs;
    std::set<uint8_t> lidars;
  };

  class LidarComponent
  {
  public:
    class Listener
    {
    public:
      virtual ~Listener() = default;
      virtual void onLidarError(const uint8_t &id, int error) = 0;
      virtual void onLidarFrame(const uint8_t &id,
                                std::shared_ptr<lpc::LidarProtoPointCloud> &&frame) = 0;
    };
    explicit LidarComponent(const LidarConfig &);
    void start(Listener *);
    void stop();
    ~LidarComponent();

  private:
    class Impl;
    Impl *impl;
  };
} // namespace lpc
